﻿using System.Collections.Generic;
using Yun.Interface;
using Yun.Response;
using Yun.Util;

namespace Yun.Pay.Request
{
    /// <summary>
    /// 用户转账
    /// chenggou.pay.transfers
    /// </summary>
    public class TransfersMoneyRequest : ITopRequest<IntResultResponse>
    {
        /// <summary>
        /// 需要转账的金额
        /// </summary>
        public double Money { get; set; }


        /// <summary>
        /// 目标用户ID
        /// </summary>
        public int TargetUserId { get; set; }


        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }


        /// <summary>
        /// IP地址
        /// </summary>
        public string Ip { get; set; }


        /// <summary>
        /// 支付密码
        /// </summary>
        public string PayPassword { get; set; }

        /// <summary>
        /// 币种
        /// </summary>
        public string Currency { get; set; }

        /// <summary>
        /// 交易标识，32位
        /// </summary>
        public string TradeNum { get; set; }



        public string GetApiName()
        {
            return "chenggou.pay.transfers";
        }

        public IDictionary<string, string> GetParameters()
        {
            var parameters = new YunDictionary
            {
                {"money", Money},
                {"targetuserid", TargetUserId},
                {"remark", Remark},
                {"ip", Ip},
                {"paypassword", string.IsNullOrWhiteSpace(PayPassword)
                    ? ""
                    : (PayPassword.Length == 32 ? PayPassword : TopUtils.EncryptAes(PayPassword, AppSecret))},
                {"tradenum",TradeNum },
                {"currency",Currency }
            };
            return parameters;
        }

        public void Validate()
        {

        }

        /// <summary>
        /// APP密匙
        /// 不要写在文档上
        /// </summary>
        public string AppSecret { get; set; }
    }
}
